<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition template="/templatePrincipal.xhtml" xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:rich="http://richfaces.org/rich">

    <ui:define name="conteudo">
        <script type="text/javascript">
            function limparCampos(){
                document.getElementById("fpLocais:itNome").value = '';
                document.getElementById("fpLocais:itCidade").value = '';
                document.getElementById("fpLocais:itBairro").value = '';
                document.getElementById("fpLocais:itLogradouro").value = '';
                document.getElementById("fpLocais:itCompletemento").value = '';
                document.getElementById("fpLocais:itCep").value = '';
            }
        </script>
        <rich:spacer height="20"/>
        <center>
            <rich:messages layout="table"
                           errorClass="errorClass"
                           infoClass="infoClass"
                           warnClass="warnClass"
                           styleClass="painelMensagem"
                           ajaxRendered="true"/>
        </center>
        <rich:spacer height="10"/>

        <rich:simpleTogglePanel switchType="client">
            <f:facet name="header">
                #{messages.telaLocalAlterar}
            </f:facet>

            <h:form id="fpLocais">
                <h:panelGrid cellspacing="2" cellpadding="2" columns="2" columnClasses="field-names, fields">


                    <h:outputLabel for="itNome" styleClass="required-black">
                        #{messages.nomeLocal}:
                    </h:outputLabel>
                    <h:inputText id="itNome" required="true" value="#{localAlteraAction.local.nome}" style="width:150px;"/>

                    <h:outputLabel for="itCidade" styleClass="required-black">
                        #{messages.cidadeLocal}:
                    </h:outputLabel>
                    <h:inputText id="itCidade" required="true" value="#{localAlteraAction.local.endereco.cidade}" style="width:150px;"/>

                    <h:outputLabel for="itBairro" styleClass="required-black">
                        #{messages.bairroLocal}:
                    </h:outputLabel>
                    <h:inputText id="itBairro" required="true" value="#{localAlteraAction.local.endereco.bairro}" style="width:150px;"/>

                    <h:outputLabel for="itLogradouro" styleClass="required-black">
                        #{messages.logradouroLocal}:
                    </h:outputLabel>
                    <h:inputText id="itLogradouro" required="true" value="#{localAlteraAction.local.endereco.logradouro}" style="width:150px;"/>

                    <h:outputLabel for="itCompletemento" styleClass="required-black">
                        #{messages.complementoLocal}:
                    </h:outputLabel>
                    <h:inputText id="itCompletemento" value="#{localAlteraAction.local.endereco.complemento}" style="width:150px;"/>

                    <h:outputLabel for="itCep" styleClass="required-black">
                        #{messages.cepLocal}:
                    </h:outputLabel>
                    <h:inputText id="itCep" value="#{localAlteraAction.local.endereco.cep}" style="width:150px;"/>

                </h:panelGrid>
                <br/>
                <h:commandLink id="clCriar"
                               action="#{localAlteraAction.alterar}"
                               styleClass="link dr-toolbar-ext rich-toolbar">
                    <h:graphicImage value="/resources/images/dialog-ok-old.png"/>
                    <h:outputText value="#{messages.botaoSalvarAlteracoes}"/>
                </h:commandLink>

                <h:commandLink id="clLimpar"
                               immediate="true"
                               onclick="limparCampos()"
                               styleClass="link dr-toolbar-ext rich-toolbar">
                    <h:graphicImage value="/resources/images/edit-clear.png"/>
                    <h:outputText value="#{messages.botaoLimpar}"/>
                </h:commandLink>

                <h:commandLink id="clVoltar"
                               immediate="true"
                               action="locais"
                               styleClass="link dr-toolbar-ext rich-toolbar">
                    <h:graphicImage value="/resources/images/edit-undo.png"/>
                    <h:outputText value=" #{messages.botaoVoltar}" />
                </h:commandLink>
            </h:form>
        </rich:simpleTogglePanel>
    </ui:define>
</ui:composition>